package com.chis.tools;

import com.chis.jm.bean.jxc.CntstmInfoBean;
import com.chis.jmdatatimer.comm.JedisConnect;
import com.chis.jmdatatimer.comm.JedisSerializeUtil;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;

import java.util.List;
import java.util.Set;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年01月26日
 */
public class TestRedis {
    public static void main(String[] args) {
//        bigdata();
        keyexit();

    }

    public static void keyexit(){
        ShardedJedisPool jedisPool = JedisConnect.getInstance().jedisPool;
        ShardedJedis jedis = jedisPool.getResource();
        jedis.select(0);
        boolean b = jedis.exists("GROUP_TEST2-TOPIC_TEST-2");
        System.out.println(b);

    }


    public static void bigdata(){
        //大数据内存库
        ShardedJedisPool jedisPool = JedisConnect.getInstance().jedisPool;
        ShardedJedis jedis = jedisPool.getResource();
        //各主题偏移量
        jedis.select(0);
        Set<byte[]> set = jedis.keys("*".getBytes());
        for (byte[] key : set) {
            System.out.println(new String(key));
        }
        System.out.println("偏移量："+jedis.get("GROUP_TEST-TOPIC_TEST-2"));
    }

    public static void jxcredis(){
        //大数据内存库
//        ShardedJedisPool jedisPool = JedisConnect.getInstance().jedisPoolJxc;
//        ShardedJedis jedis = jedisPool.getResource();
//        //各主题偏移量
//        jedis.select(0);
//        Set<byte[]> set = jedis.keys("*".getBytes());
//        for (byte[] key : set) {
//            System.out.println(new String(key));
//        }
        //查疫苗
//        List<CntstmInfoBean> cntstmInfoBeans = (List<CntstmInfoBean>) JedisSerializeUtil.unserialize(jedis.get(unitCode.getBytes()));
//        for(CntstmInfoBean t : cntstmInfoBeans){
//            if(t.getBatnmb().equals(batmnb)){
//                System.out.println("查到了："+"库存编码"+t.getGuid()+"批号："+t.getBatnmb()+"数量："+t.getStmCnt()+"仓库："+t.getStorageName());
//            }
//        }
//        System.out.println("查询结束");
    }
}
